<?php
/**
 * POD
 *
 * ${license}
 *
 * @category	POD
 * @package		POD_Loader
 * @copyright	${copyright}
 * @license		${license}
 * @version		${$version}
 * @author		Ziv Perry (http://zivperry.com)
 */


class POD_Loader {

	private $libPath = '';
	
	/**
	 * @return POD_Loader
	 */
	public function init() {
		$this->libPath = realpath(dirname(dirname(__FILE__)));
		spl_autoload_register(array($this, 'loader'));
		return $this;
	}
	
	public function loader($className) {
		if (0 !== strpos($className, 'POD_')) {
			return;
		}
		$classNamePath	= str_replace('_', '/', $className);
		$classPath		= "{$this->libPath}/{$classNamePath}.php";
		require_once $classPath;
	}
	
	/**
	 * @var POD_Loader
	 */
	private static $instance = null;
	
	/**
	 * @return POD_Loader
	 */
	public static function getInstance() {
		if (null === self::$instance) {
			self::$instance = new POD_Loader();
		}
		return self::$instance;
	}
	
	private function __construct() {}
	private function __clone() {}
}